﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.BIM;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.HYSpace
{
	public partial class FrmModifyRoomName : System.Windows.Forms.Form
	{
		public FrmModifyRoomName(int roomUseId)
		{
			this.InitializeComponent();
			this.rUseId = roomUseId;
			base.Icon = Resource.YArchitechIcon;
		}

		private void FrmModifyRoomName_Load(object sender, EventArgs e)
		{
			foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfoGrid.listSPI)
			{
				if (this.rUseId == spaceParameterInfo.RoomId)
				{
					this.txtRoomType.Text = spaceParameterInfo.RoomTypeName;
					this.txtRoomName.Text = spaceParameterInfo.RoomName;
					this.txtRoomName.Tag = spaceParameterInfo.RoomName;
				}
			}
		}

		private void btnCancle_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void btnSure_Click(object sender, EventArgs e)
		{
			int num = 0;
			foreach (SpaceParameterInfo spaceParameterInfo in FrmShowInfo.listSPI)
			{
				if (spaceParameterInfo.RoomId == this.rUseId)
				{
					num = spaceParameterInfo.RoomTypeId;
				}
			}
			this.roomName = this.txtRoomName.Text.Trim();
			string a = Convert.ToString(this.txtRoomName.Tag);
			bool flag = false;
			foreach (SpaceParameterInfo spaceParameterInfo2 in FrmShowInfo.listSPI)
			{
				if (spaceParameterInfo2.RoomTypeId == num && this.roomName == spaceParameterInfo2.RoomName && a != this.roomName)
				{
					this.txtRoomName.Focus();
					this.txtRoomName.SelectAll();
					YJKMessageBox.Show("同类型空间，不能重名，请重新填写！");
					flag = true;
					break;
				}
			}
			if (flag)
			{
				return;
			}
			base.DialogResult = DialogResult.Yes;
		}

		private int rUseId;

		public string roomName = "";
	}
}
